package com.simonall.utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import com.simonall.listen.PropertyListener;

import cn.hutool.core.util.CharsetUtil;

/**
 * 属性加载器
 * 
 * @author simonall
 */
public class PropertyLoader {

	/**
	 * 属性加载
	 * 
	 * @param fileName 名称【application.properties】
	 */
	public static Properties load(String fileName) throws IOException {
		return load(fileName, CharsetUtil.UTF_8);
	}

	/**
	 * 属性加载
	 * 
	 * @param fileName 名称
	 * @param charset  编码
	 */
	public static Properties load(String fileName, String charset) throws IOException {
		Properties properties = new Properties();
		InputStream in = PropertyListener.class.getClassLoader().getResourceAsStream(fileName);
		properties.load(new BufferedReader(new InputStreamReader(in, charset)));
		return properties;
	}
}
